from faker import Faker


def CreatUsr():
    n = 10
    cn = Faker(locale='zh_CN')
    f = Faker()
    userCsv = open('users.csv', 'w')
    global userId
    userId = []
    print('id,name,phone,pwd', file=userCsv)
    for i in range(n):
        uid = f.first_name_male()if i & 1 else f.first_name_female()
        userId.append(uid)
        print(uid, cn.name_male()if i & 1 else cn.name_female(), cn.phone_number(),
              f.pystr(3, 5)+str(f.pyint(100000, 100000000)), sep=',', file=userCsv)


def CreatMov():
    n = 100
    fk = Faker()
    f = open('movies.csv', 'w')
    global movieId
    movieId = [fk.pyint() for _ in range(n)]

    print('movieId,movieName,actors,movieAmount,content', file=f)

    for i in range(n):
        print(movieId[i], fk.word(), fk.name()+' '+fk.name(),
              fk.pyint(), fk.paragraph()+fk.paragraph(), sep=',', file=f)


def CreatRts():
    n = 500
    f = open('ratings.csv', 'w')
    print('userId,movieId,rating', file=f)
    from random import choice, randint
    for _ in range(n):
        print(choice(userId), choice(movieId),
              randint(0, 10)/2, sep=',', file=f)


CreatUsr()
CreatMov()
CreatRts()
